home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3392 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: castle.nando.net!news
  2. From: actuary@nando.net   (Bill McCarthy)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Calculation in C: HELP
  5. Date: 28 Jan 1996 17:45:04 GMT
  6. Organization: News & Observer Public Access
  7. Message-ID: <4egcn0$bta@castle.nando.net>
  8. References: <4eddjd$mde@newsbf02.news.aol.com>
  9. Reply-To: actuary@nando.net (Bill McCarthy)
  10. NNTP-Posting-Host: vyger713.nando.net
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <4eddjd$mde@newsbf02.news.aol.com>,
  14. queenhead@aol.com (Queenhead) writes:
  15.  
  16. >Hi. I am trying to use the following calculation in a program and it is
  17. >not coming out right:
  18. >
  19. >nextyr  = rate  *  currentyr  *  ( 1 - (currentyr/1000000)
  20. >
  21. >Is something wrong with that (in terms of C syntax)?  I should be getting
  22. >234,000   if rate is 2.6 and currentyr is 100,000. My program is not
  23. >giving me that.
  24.  
  25. You should post small complete code.  That line above should produce
  26. a syntax error, since its missing a ");" at the end.
  27.  
  28. Assuming your variables are all declared doubles and ints are 32 bit,
  29. your line of code should work fine.  If ints are 16 bit, then 1000000
  30. will not fit (you could add an "L" if it fits in long, or add a "." to make
  31. it a double).
  32.  
  33. Bill McCarthy
  34. actuary@nando.net
  35. Wendell, NC  USA
  36.  
  37.